<template>
	<view class="page">
		<u-navbar
				:title="pageTitle"
				bgColor="rgba(0,0,0,0)"
				@rightClick="rightClick"
				:autoBack="true"
		>
		</u-navbar>
		<u--image :showLoading="true" :src="goodsInfo.img" width="100%" height="563rpx" @click="click"></u--image>
		<view class="godds-info">
			<u--text :text="goodsInfo.goodsName" color='#000' size='36rpx' @click="clickHandler"></u--text>
			<view class="count-price">
				<view class='count-price-item'><u--text :text="`库存${goodsInfo.stuck}${goodsInfo.unit}`" color='rgba(153, 153, 153, 1)' size='26rpx'></u--text></view>
				<view class='count-price-item'><u--text mode="price" color='#D74040' :text="goodsInfo.price"></u--text></view>
			</view>
			<view class="buy-btn"><u-button class='' type="primary" shape="circle" color="rgba(13, 13, 212, 1)" text="加入购物车"></u-button></view>	
		</view>
		<view class="rich-text">
			<view class="block-title"><u--text text="商品介绍" color='#000' size='36rpx'></u--text></view>
			<rich-text :nodes='nodes'></rich-text>
		</view>
	</view>
</template>

<script>
	import { formatHtml } from '@/util/utils.js'
	export default {
		data() {
			return {
				pageTitle: '',
				goodsInfo: {
					img: 'https://img.js.design/assets/img/62cfcaf91633ae9ab1169366.jpg',
					goodsName: '魏牌-激光蓝牙音箱',
					stuck: 12,
					price: 1600,
					unit: '桶',
					nodes: `<img src="https://img.js.design/assets/img/62cfcaf91633ae9ab1169366.jpg" alt="">
								<p>商品介绍</p>
								<p>商品介绍</p>
								<p>商品介绍</p>
								<p>商品介绍</p>`,
				}
			};
		},
		computed: {
			nodes() {
				return formatHtml(this.goodsInfo.nodes)
			}
		},
		methods: {
			clickHandler(e) {
				console.log(e)
			}
		}
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #F6F5FA;
}
.godds-info{
	box-sizing: border-box;
	padding: 28rpx 20rpx 26rpx;
	background-color: #FFF;
	position: relative;
	.count-price{
		margin-top: 16rpx;
		display: flex;
		justify-content: flex-start;
		.count-price-item{
			margin-right: 30rpx;
			flex-grow: 0;
		}
	}
	.buy-btn{
		position: absolute;
		right: 20rpx;
		bottom: 32rpx;
		width: 173rpx;
		height: 66rpx;
	}
}
.rich-text{
	margin-top: 10rpx;
	box-sizing: border-box;
	padding: 28rpx 20rpx;
	background-color: #FFF;
	overflow: hidden;
	.block-title{
		padding-bottom: 20rpx;
	}
}


</style>
